<?php
set_time_limit(0);
require_once("IXR_Library.php.inc");
 
$client->debug = true; // Set it to fase in Production Environment
 
// Create the client object
$client = new IXR_Client('http://localhost/wpamazon/xmlrpc.php');
 
 $username = "admin"; 
 $password = "1234"; 
 $params = array(0,$username,$password,10); // Last Parameter tells how many posts to fetch
 
// Run a query To Read Posts From Wordpress
if (!$client->query('metaWeblog.getRecentPosts', $params)) {
    die('Something went wrong - '.$client->getErrorCode().' : '.$client->getErrorMessage());
}
 
$myresponse = $client->getResponse();
 
$i=0; ?>
 
<table border="1" cellpadding="0" cellspacing="2">
<tr>
<td>Sr. No</td>
<td>Date</td>
<td>Author</td>
<td>Post Id</td>
<td>Title</td>
<td>Categories</td>
<td>Tags</td>
<td>Status</td>
<td>Field</td>
</tr>
<?php //foreach ($myresponse as $key => $value)
foreach ($myresponse as $res)
{ 
 
  if($res['post_status']!="draft"){
   //$times = new IXR_Date(); ?>
	<tr>
		<td><?php echo $i+1; ?></td>
		<td>
		<?php
		$object = $res['dateCreated'];
		 echo $object->day."-".$object->month."-".$object->year." ".$object->hour.":".$object->minute; ?></td>
		<td><?php echo $res['wp_author_display_name']; ?></td>
		<td><?php echo $res['postid']; ?></td>
		<td><a href="<?php echo $res['permaLink']; ?>"><?php echo $res['title']; ?></a></td>
		<td>
			<?php  echo implode($res['categories'],", ")  ?>			
		</td>
		<td><?php echo $res['mt_keywords']; ?></td>
		<td><?php echo $res['post_status']; ?><?php print_r($res['custom_fields']); ?></td>
		 <td><?php 
		 $arrayvalue1=array();
		 foreach($res['custom_fields'] as $index => $valuearray){ 
		 $strvalue1="";
		 
		 $strvalue1.= "'$index'=>array(";
		 $arrayvalue2=array();
		 foreach($valuearray as $key =>$value2)
		 {
			 $value2=mysql_real_escape_string($value2);
			  $arrayvalue2[]="'$key'=>'$value2'";
		 }
		      $strvalue1.= join(",",$arrayvalue2).")"; 
		 $arrayvalue1[]=$strvalue1;
		 } 
		 echo join(",",$arrayvalue1);
		 
		 ?></td>
	</tr>  
<?php $i++;	} } ?>
</table>